import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
import java.util.Scanner;

public class E_1_31 {
    public static void main(String[] args) {
        int num;
        Scanner sc = new Scanner(System.in);
        num = sc.nextInt();
        for (int i = 0; i < num; i++) {
            int l = sc.nextInt();
            int r = sc.nextInt();
            int n1=0,n2=0;
            List<Integer> list = new ArrayList<>();
            List<Integer> list2 = new ArrayList<>();
            for (int j = 1; j < l; j++) {
                if (l%j==0)
                    list.add(j);
            }
            for (int j = 1; j < r; j++) {
                if (r%j==0)
                    list2.add(j);
            }
            for (Integer integer : list) {
                n1 = n1 + integer;
            }
            for (Integer integer : list2) {
                n2 = n2 + integer;
            }
            if (n1==r&&n2==l){
                System.out.println("YES");
            }else {
                System.out.println("NO");
            }

        }
    }
}
